package cn.edu.nit.sys.entity;

import cn.edu.nit.sys.enums.FlowEnum;
import cn.edu.nit.sys.enums.LeaveTypeEnum;
import cn.edu.nit.sys.enums.UserEnum;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.util.List;

/**
 * @Author xiaobai
 * @Date 2023/3/19 19:30
 * @Version 1.0.0
 */
@Data
@TableName("sys_leave")
public class Leave {

    @TableId(type = IdType.ASSIGN_ID)
    private String id;
    private String name;
    private int day;
    @TableField(exist = false)
    private String typeCode;
    private LeaveTypeEnum type;
    private String leaveType;
    private String userId;
    private String reason;
    private String flow;
    private String imgs;
    @TableField(exist = false)
    private FlowEnum flowLabel;
    private String createTime;

    @TableField(exist = false)
    private List<Approve> approveList;

    public String getTypeCode() {
        return LeaveTypeEnum.getCode(this.type);
    }

    public FlowEnum getFlowLabel() {
        if("0".equals(this.flow)) {
            return FlowEnum.ONE;
        }else if("1".equals(this.flow)) {
            return FlowEnum.TWO;
        }else if("2".equals(this.flow)) {
            return FlowEnum.THREE;
        }else if("3".equals(this.flow)) {
            return FlowEnum.FOUR;
        }
        return FlowEnum.FIVE;
    }
}
